<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .big,
        .bigfont {
            width: 400px;
            height: 400px;
            background-color: red;
        }
        .sm,
        .smfont {
            width: 200px;
            height: 200px;
            background-color: greenyellow;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- 最常用的v-bind和v-on才有对应的缩写：@以及:,语法糖 -->
        <p :title="msg">v-bind指令。绑定标签属性，使得属性值成功一个变量。如果不加v-bind，就是字符串</p>
        <div :qwer="df"></div>
        <p>动态样式---数据的变化导致页面样式的变化</p>
        <button @click="toggle">toggle</button>
        <!-- 1.变量替换和字符串拼接 -->
        <div :class="c1+'font'"></div>
        <!-- 2.判断 -->
        <div :class="{active: isActive}">只有符合条件时才有class</div>
        <div :class="isActive?'active': 'normal'">各个情况下都有不同的class</div>
        <!-- 3.包罗万象 -->
        <div :class="['c2', {active1: isActive}, isActive?'active2': 'normal']">
            通过数组包裹，里面呢可以有固定的class，也有动态class
        </div>
        <hr>
        <div :style="{color: co1, fontSize: size+'px'}">动态样式---style的变化</div>
        <div :style="freeStyle">动态样式---style的变化</div>
    </div>
    <script src="../0511/js/vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                msg: '我是p标签',
                df: 'lolm',
                c1: 'big',
                isActive: false,
                co1: '#56a5f1',
                size: 40,
                freeStyle: {
                    width: '100px',
                    height: '100px',
                    border: '1px solid red'
                }
            },
            methods: {
                toggle() {
                    // 通过操作变量，控制class，进而控制页面样式
                    this.c1 === 'big' ? this.c1='sm': this.c1='big'
                    this.co1 = 'red'
                }
            }
        })
    </script>
</body>
</html>